package com.linjacy.container.product.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.linjacy.container.product.entity.StandardEntity;
import com.linjacy.container.product.service.StandardService;
import com.linjacy.common.utils.PageUtils;
import com.linjacy.common.utils.R;



/**
 * 
 *
 * @author linjacy
 * @email 939886352@gmail.com
 * @date 2021-01-03 16:04:54
 */
@RestController
@RequestMapping("product/standard")
public class StandardController {
    @Autowired
    private StandardService standardService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = standardService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{containerNum}")
    public R info(@PathVariable("containerNum") Long containerNum){
		StandardEntity standard = standardService.getById(containerNum);

        return R.ok().put("standard", standard);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody StandardEntity standard){
		standardService.save(standard);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody StandardEntity standard){
		standardService.updateById(standard);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] containerNums){
		standardService.removeByIds(Arrays.asList(containerNums));

        return R.ok();
    }

}
